﻿#ifndef REPORTMANAGER_H
#define REPORTMANAGER_H

#include <QObject>
#include <QDateTime>
#include <QFileDialog>
#include "wordExporter.h"
#include "excelExporter.h"
#include "DbHelper.h"
#include "GetMessageInterface.h"

// 打印报告
class ReportManager : public QObject
{
    Q_OBJECT
private:
    ReportManager();

public:

    enum ExportType{
        WORD = 0,
        EXCEL = 1,
        CSV = 2
    };

    static ReportManager& I();

    Q_INVOKABLE bool        setGmiInterface(GetMessageInterface* gmi);

    // 导出设置
    Q_INVOKABLE bool        setExportPath(QString path);
    Q_INVOKABLE bool        setExportType(ExportType type);
    Q_INVOKABLE bool        setAutoExport(bool state);
    Q_INVOKABLE QString     getExportPath();
    Q_INVOKABLE int         getExportType();
    Q_INVOKABLE bool        getAutoExport();
    Q_INVOKABLE bool        updateExportInfo(QString path, int type, bool autoExport);
    Q_INVOKABLE QString     selectExportPath();

    // 更新实验信息;
    Q_INVOKABLE int         setReportIdx(int idx = -1);     // -1时，更新为最新的idx
    void                    setReportInfo(QVariantMap expInfo, QVariantList logInfo);
    QVariantMap             getExperimentInfo();
    QVariantList            getLogInfo();


    // 导出报告
    Q_INVOKABLE int         exportReport_auto();                 // 自动导出(导出两份)
    Q_INVOKABLE int         exportReport(QString path);     // 根据已有信息在指定路径导出
    Q_INVOKABLE int         exportReport(QString path, QVariantMap expInfo, QVariantList logInfo);      // 指定实验信息和日志信息
    Q_INVOKABLE int         exportReport_fileDialog();      // 调用FileDialog选择路径
    Q_INVOKABLE int         exportReport_fileDialog(QVariantMap expInfo, QVariantList logInfo);

    // ......我怎么写出来这么多函数


private:

    QVariantMap   _expInfo;
    QVariantList  _logInfo;

    GetMessageInterface* gmi = nullptr;


    ExportType      _exportType = WORD;
    QString         _exportPath = "./datao";
    bool            _autoExport = true;
    QStringList     _typeSuffix = {".docx", ".xlsx", ".csv"};


};

#endif // REPORTMANAGER_H
